#include "Player.h"

int Player::findPiece(float ex, float why)
{
	for(int i = 0; i < numberOfPieces; i++)
	{
		if((pieces[i].getX() == ex) && (pieces[i].getY() == why))
		{
			return i;
		}
	}
	return -1;
}

Player::~Player()
{
	delete pieces;
}

void Player::setPieces()
{
	pieces = new Piece[numberOfPieces];
	for(int i = 0; i < numberOfPieces; i++)
	{
		pieces[i].setColor(color);
	}
}

void Player::move(int num, float ex, float why)
{
	pieces[num].move(ex, why);
}

void Player::drawPiece()
{
	Rect<float> hi(-0.9, 0.9, 0.05, 0.05);
	switch(color)
	{
	case 0:
		glColor3ub(255, 0, 0);
		break;
	case 1:
		glColor3ub(0, 255, 0);
		break;
	case 2:
		glColor3ub(255, 200, 0);
		break;
	case 3:
		glColor3ub(0, 0, 255);
		break;
	}
	hi.glDraw();
}

void Player::glDraw()
{
	for(int i = 0; i < numberOfPieces; i++)
	{
		pieces[i].glDraw();
	}
}